<template>
  <div>
    <!-- <div class="center-s clearfix">
    <el-button type="primary" plain class="clickBack" @click="returnBack()">返回</el-button>
    </div> -->
    <div class="div-mau" style="padding:60px 60px;">
      <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="120px">
          <el-row>
              <el-col :span="12">
                  <el-form-item label="证书类型" prop="certificateType">
                    <el-select v-model="dataForm.certificateType" :disabled="disabledRow" @change="changeCertificateType" style="width:100%">
                      <el-option
                        v-for="item in certificateTypes"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                        >
                      </el-option>
                    </el-select>
                  </el-form-item>
              </el-col>
              <el-col :span="12">
                  <el-form-item label="证书名称" prop="name">
                  <el-input v-model="dataForm.name" placeholder="请填写证书名称"></el-input>
                  </el-form-item>
              </el-col>
              <!-- 新增人员的按钮 s-->
              <!-- 新增人员的按钮 e-->
          </el-row>
          <el-row>
              <el-col :span="12">
                <el-form-item label="证书编号" prop="code">
                  <el-input v-model="dataForm.code" placeholder="请填写证书编号"></el-input>
                </el-form-item>
              </el-col>

              <el-col v-if="dataForm.certificateType == 1" :span="12">
                <el-form-item class="zizhixiang" label="资质项" prop="qualifications">
                  <!-- <el-input v-model="dataForm.qualification" placeholder="请填写资质项"></el-input> -->
                  <el-select
                    class="select-s"
                     v-model="dataForm.qualifications"
                     multiple
                     collapse-tags
                     ref="staSelect"
                     @focus="clickFocus()"
                     @blur="clickBlur()"
                     style="width: 100%;"
                     placeholder="请选择">
                     <el-option
                       v-for="item in checkList"
                       :key="item.id"
                       :label="item.name"
                       :value="item.id">
                     </el-option>
                  </el-select>
                </el-form-item>
                </el-col>

              <el-col v-if="dataForm.certificateType == 2" :span="12">
                <el-form-item label="发证机构">
                  <el-input v-model="dataForm.releaseOrgan" placeholder="请填写发证机构"></el-input>
                </el-form-item>
              </el-col>
              <el-col v-if="dataForm.certificateType == 3" :span="12">
                <el-form-item label="证书级别">
                  <el-select v-model="dataForm.level" style="width:100%">
                      <el-option
                        v-for="item in levels"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                        >
                      </el-option>
                    </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="发证日期">
                  <el-date-picker type="date" v-model="dataForm.releaseDate" placeholder="选择发证日期" style="width:100%"></el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="到期日期">
                  <el-date-picker type="date" v-if="!checked" v-model="dataForm.expireDate" placeholder="选择证书到期日期" style="width:78%" :picker-options="pickerOptionsValidityEndTime"></el-date-picker>
                  <el-checkbox style="width:20%;" v-model="checked" label="长期有效" border size="medium"></el-checkbox>
                </el-form-item>
              </el-col>
              <el-col v-if="dataForm.certificateType == 3" :span="12">
                  <el-form-item label="发证机构">
                    <el-input v-model="dataForm.releaseOrgan" placeholder="请填写发证机构"></el-input>
                  </el-form-item>
                </el-col>
          <!-- 资质证书的切换 -->
                <el-col v-if="dataForm.certificateType == 1 || dataForm.certificateType == 4" :span="12">
                  <el-form-item label="发证机构">
                    <el-input v-model="dataForm.releaseOrgan" placeholder="请填写发证机构"></el-input>
                  </el-form-item>
                </el-col>
                <el-col v-if="dataForm.certificateType == 1 || dataForm.certificateType == 4" :span="12">
                  <el-form-item label="法人姓名">
                    <el-input v-model="dataForm.corporateName" maxlength="11" placeholder="请填写法人姓名"></el-input>
                  </el-form-item>
                </el-col>
                <el-col v-if="dataForm.certificateType == 1 || dataForm.certificateType == 4" :span="12">
                  <el-form-item label="注册地址">
                    <el-input v-model="dataForm.registeredAddress" placeholder="请填写注册地址"></el-input>
                  </el-form-item>
                </el-col>
                <el-col v-if="dataForm.certificateType == 1 || dataForm.certificateType == 4" :span="12">
                  <el-form-item label="注册资本(万元)" prop="registeredCapital">
                    <el-input-number v-model="dataForm.registeredCapital" placeholder="请填写注册资本"></el-input-number>
                  </el-form-item>
                </el-col>
            <!-- ios证书的切换 -->
                <el-col v-if="dataForm.certificateType == 2" :span="12">
                  <el-form-item label="认证机构">
                    <el-input v-model="dataForm.authOrgan" placeholder="请填写认证机构"></el-input>
                  </el-form-item>
                </el-col>
                <el-col v-if="dataForm.certificateType == 2" :span="12">
                  <el-form-item label="认证标准">
                    <el-input v-model="dataForm.authStandards" maxlength="11" placeholder="请填写认证标准"></el-input>
                  </el-form-item>
                </el-col>
                <el-col v-if="dataForm.certificateType == 2" :span="12">
                  <el-form-item label="认证范围">
                    <el-input v-model="dataForm.coverage" placeholder="请填写认证范围"></el-input>
                  </el-form-item>
                </el-col>

                <el-col :span="24">
                  <el-form-item label="备注">
                    <el-input
                      type="textarea"
                      :rows="4"
                      placeholder="请输入备注"
                      v-model="dataForm.remark"
                      >
                      </el-input>
                  </el-form-item>
                </el-col>
            </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="上传证书扫描件">
                <el-upload
                 :action="uploadUrl()"
                  accept =".jpg,.png"
                  :headers="myHeader"
                  :limit="limitNum"
                  :on-success="onCertiSuccess"
                  :show-file-list="showList"
                  :file-list="img"
                  :on-error="onError"
                  ref="certiUpload"
                  list-type="picture-card"
                 >
                 <i slot="default" class="el-icon-plus"></i>
                 <div slot="file" slot-scope="{file}">
                <img
                  class="el-upload-list__item-thumbnail"
                  :src="file.url" alt=""
                >
                <span class="el-upload-list__item-actions">
                 <span
                 class="el-upload-list__item-preview"
                 @click="imgHandlePictureCardPreview(file)"
                >
                <i class="el-icon-zoom-in"></i>
               </span>
               <span
                 v-if="!disabled"
                 class="el-upload-list__item-delete"
                 @click="imgHandleRemove(file)"
               >
                 <i class="el-icon-delete"></i>
               </span>
              </span>
             </div>
             </el-upload>
             <el-dialog :visible.sync="imageDialogVisible">
             <img width="100%" :src="imgDialogImageUrl" alt="">
             </el-dialog>
             <!-- 上传图片 -->
              </el-form-item>
            </el-col>
          </el-row>
          <el-form-item style="text-align:center;padding-right:120px;">
            <el-button class="button-see" size="mini" plain @click="gotoRouteHandle()">返 回</el-button>
            <el-button class="button-see" size="mini" type="primary" @click="dataFormSubmit()">保 存</el-button>
          </el-form-item>
      </el-form>
      <el-dialog
      title="错误提示"
      :visible.sync="dataFormSubmitCenterDialogVisible"
      width="30%"
      center>
      <span class="cuowu">上述必填信息有误，请填写完整！</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dataFormSubmitCenterDialogVisible = false">关 闭</el-button>
      </span>
      </el-dialog>
      <!-- 资质项选择 -->
      <el-dialog
       title="选择资质项"
       class="dialog-s"
       :visible.sync="centerDialogVisible"
       width="60%"
       @opened="openedEdit()"
       >
       <span>
      <div class="sousuo">
        <div class="guanjianzi">
          <span class="ziti">关键字</span>
          <el-input class="inputss" v-model="dataGet.name" placeholder="请输入关键字" style="width:50%"></el-input></div>
        <div class="buttons">
          <el-button size="mini" type="primary" class="buttonItema" @click="clickChong()">重 置</el-button>
          <el-button size="mini" type="primary" class="buttonItemb" @click="clickSou()">搜 索</el-button>
        </div>
      </div>
      <!-- @selection-change="selectionChangeHandle" -->
      <el-table
      :data="dataGetForm"
      :row-key="(row) => row.id"
      @sort-change='sort_change'
      v-loading="dataListLoading"
      ref="multipleTable"
       height="600"
      :header-cell-style="{background:'#F5F7FA'}"
      style="width: 100%;">
      <el-table-column
      type="selection"
      :reserve-selection="true"
      width="55">
    </el-table-column>
      <el-table-column
        prop="name"
        min-width="110"
        sortable='custom'
        align="center"
        label="证书项">
      </el-table-column>
      <el-table-column
        prop="levels"
        align="center"
        width="150"
        sortable='custom'
        label="资质等级"
       >
       <template slot-scope="scope">
        <el-select v-model="scope.row.levelsValue" placeholder="请选择">
        <el-option
         v-for="item in scope.row.levels"
         :key="item.value"
         :label="item.label"
         :value="item.value">
        </el-option>
        </el-select>
       </template>
      </el-table-column>
    </el-table>
    <!-- <el-pagination
      background
      ref="pagHe"
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[5, 10, 20, 50, 100, 200]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, prev, pager, next, sizes, jumper">
    </el-pagination> -->
       </span>
       <span slot="footer" class="dialog-footer">
         <el-button size="mini" class="button-see" @click="centerDialogVisible = false">取 消</el-button>
         <el-button size="mini" class="button-see" type="primary" @click="clickCheck()">确 定</el-button>
       </span>
     </el-dialog>
    </div>
    <!-- 新增人员组件 -->
  </div>
</template>

<script>
  import Vue from "vue"
  import ElTreeSelect from "@/components/treeSelect/index.vue"
  import AddOrUpdate from "@/views/modules/company/em/employee-add-or-update.vue"
  export default {
    name:'SubfolderManual',
    data () {
      var checkMobile = (rule, value, cb) => {
      // 验证手机号的正则表达式
      const regMobile = /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
      if (regMobile.test(value)) {
        return cb();
      }
      cb(new Error("请输入合法的手机号"));
    };
      return {
        centerDialogVisible:false,
        dataListLoading: false,
        dataFormSubmitCenterDialogVisible:false,
        imageDialogVisible:false,
        imgDialogImageUrl:'',
        disabled: false,
        // pageIndex: 1,
        // pageSize: 10,
        // totalPage:0,
        valueList:'',
        disabledRow:false,
        readonly:false,
        readonlyEdit:false,
        visible: false,
        dataGetForm:[],
        levelsIds:[],
        pitchList:[],
        isisa:[],
        dataGet:{
          name:''
        },
        checked: false,
        dataEdit:[],
        addOrUpdateVisible: false,
        certificateTypes:[{
          value: 1,
          label: '资质证书'
        }, {
          value: 2,
          label: 'ISO证书'
        }, {
          value: 3,
          label: '荣誉证书'
        },
        {
          value: 4,
          label: '其他证书'
        }
        ],
        dataForm: {
          certificateType: 1,
          name:'',
          code:'',
          qualifications:[],
          releaseDate:'',
          expireDate:'',
          releaseOrgan:'',
          corporateName:'',
          registeredAddress:'',
          registeredCapital:'',
          remark:'',
          longTerm:0,
          // iso
          authOrgan:'',
          authStandards:'',
          coverage:'',
          // 荣誉
          level:1,
        },
        levels:[{
          value: 1,
          label: '国家级'
        },{
          value: 2,
          label: '省级'
        },{
          value: 3,
          label: '市级'
        },{
          value: 4,
          label: '其他'
        }
        ],
        payment:'',
        valueAT:'',
        pickerOptionsValidityEndTime: {
          disabledDate: (time) => {
            return time.getTime() < this.dataForm.releaseDate;
          }
        },
        pickerOptionsBorrowEndTime: {
          disabledDate: (time) => {
            return time.getTime() < this.dataForm.borrowTime;
          }
        },
        dataRule: {
          certificateType: [
            { required: true, message: '请选择证书类型', trigger: 'blur' }
          ],
          name: [
            { required: true, message: '请填写证书名称', trigger: 'blur' }
          ],
          idType: [
            { required: true, message: '请选择证书类型', trigger: 'blur' }
          ],
          code: [
            { required: true, message: '请填写证书编号', trigger: 'blur' }
          ],
          qualifications:[
            { required: true, message: '请填写资质项', trigger: 'blur' }
          ],
          releaseTime: [
            { required: true, message: '请选择发证日期', trigger: 'blur' }
          ],
          companyEndTime: [
            { required: true, message: '请选择离职日期', trigger: 'blur' }
          ],
          validityEndTime: [
            { required: true, message: '请选择证书到期日期', trigger: 'blur' }
          ],
          keepDeptId: [
            { required: true, message: '请选择保管单位', trigger: 'blur' }
          ],
          keepUserId: [
            { required: true, message: '请选择保管人', trigger: 'blur' }
          ],
          profession: [
            { required: true, message: '请选择专业', trigger: 'blur' }
          ],
          remark: [
            { required: true, message: '请选择备注信息不能为空', trigger: 'blur' }
          ],
          borrowTime: [
            { required: true, message: '请选择借入时间', trigger: 'blur' }
          ],
          borrowEndTime: [
            { required: true, message: '请选择到期日期', trigger: 'blur' }
          ],
          orgName: [
            { required: true, message: '请填写来源企业名称', trigger: 'blur' }
          ],
          contact: [
            { required: true, message: '请填写联系人', trigger: 'blur' }
          ],
          contactMobile: [
            { required: true, len:11, message: '请填写联系人手机号', trigger: 'blur' }
          ]
        },
        treeData: [],
        certiPicList:[],
        constractPicList:[],
        payPic:[],
        jobs: [],
        checkList:[],
        dataListName:{},
        limitNum: 1, // 上传excell时，同时允许上传的最大数
        jobName:'',
        confInfos: [],
        professions: [],
        employees: [],
        getCheck:[],
        a:'',
        dialogImageUrl: '',
        dialogVisible: false,
        disabled: false,
        showList: true,
        area: {11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江",
          31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北",
          43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏",
          61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"
        },
      }
    },
    props:{
          dateFrom: {
            type: Object,
            // required: true
          },
          img: {
            type: Array
          },
          isField: {
            type: Boolean,
            // required: true
          },
          dataListForm: {
            type: Object,
          },
          editmodification: {
            type: Boolean,
          },
          // 资质
          qualification:{
            type: Boolean,
          },
          dataRow:{
            type: Object,
          },
          // iso
          ISO:{
            type: Boolean,
          },
          dataIsoRow:{
            type: Object,
          },
          // 荣誉
          honorEdit:{
            type: Boolean,
          },
          dataHonorRow:{
            type: Object,
          },
          // 其他
          restEdit:{
            type: Boolean,
          },
          dataRestRow:{
            type: Object,
          },
          abc:{
            type: Boolean,
          }
    },
    components: {
      ElTreeSelect,
      // CertificateUpdate
      AddOrUpdate
    },
    computed: {
      myHeader(){
        return {
          "token":Vue.cookie.get('token')
        }
      }
    },
    created(){
    this.newCertificate()
    console.log(this.img);
    if(this.img[0].url == null){
    this.img = []
    }
    },
    watch: {
    },
    methods: {
      clickBlur(){
      this.$refs.staSelect.blur()
      },
      clickFocus(){
      this.centerDialogVisible = true
      this.getDataGetFrom()
      this.clickBlur()
      this.openedEdit()
      // console.log(this.pitchList);
      // console.log(123);
      // this.pitchList.forEach(row => {
      //       console.log(row);
      //       this.$refs.multipleTable.toggleRowSelection(row,true);
      //     });
      // if(this.dataForm.qualification !== []){
      // }
      // this.toggleSelection()
      },
      sort_change(column){
      if(column.order =='ascending'){
        this.ascFlag = true
      }
      if(column.order =='descending'){
        this.ascFlag = false
      }
      this.getDataList()
      },
      clickCheck(){
      this.dataForm.qualifications = []
      this.levelsIds = []
      console.log(this.$refs.multipleTable.selection);
      this.checkList = this.$refs.multipleTable.selection
      console.log(this.checkList);
      this.checkList.forEach((c) =>{
        this.dataForm.qualifications.push(c.id);
        this.levelsIds.push(c.levelsValue)
      }
      )
      console.log(this.dataForm.qualifications);
      console.log(this.checkList);
      this.centerDialogVisible = false
      },
      getDataGetFrom(){
        if(this.dataGet.name == ''){
          this.dataGet.name = null
        }
        this.$http({
          url: this.$http.adornUrl('/cert/entQualiConf/getQualifications'),
          method: 'post',
          data: this.$http.adornData({
            'page': 1,
            'limit': 100,
            // 'ascFlag':this.ascFlag,
            'name':this.dataGet.name,
          })
        }).then(({data}) => {
           if(data.code === 0){
            this.dataGetForm = data.data.list.forEach(item => {
　　          this.$set(item,'levelsValue',item.levels[0])
            })
            this.dataGetForm = data.data.list.map(val => {
              val.levels = val.levels.map(v => ({
                label: this.judgeLevel(v) + '级',
                value: v
              }))
              return val
            })
            // data.data.forEach
            this.totalPage = data.data.totalCount
            // console.log(this.dataGetForm);
         }
        })
      },
      judgeLevel(val) {
        if(val == 0) {
          return '特'
        }
        if(val == 1) {
          return '一'
        }
        if(val == 2) {
          return '二'
        }
        if(val == 3) {
          return '三'
        }
        if(val == 4) {
          return '不分等'
        }
      },
      openedEdit(){
      this.dataGetForm.forEach((a) =>{
        // console.log(a);
        this.dataForm.qualifications.forEach((b) =>{
          if(a.id === b){
            // this.isisa.push(a)
            this.$refs.multipleTable.toggleRowSelection(a, true)
          }
        })
      })
      // console.log(this.isisa);
      console.log(this.checkList);
      this.checkList.forEach((u,index)=>{
        // console.log(u);
        u.levelsValue = this.levelsIds[index]
      })
      this.dataGetForm.forEach((i) =>{
        this.checkList.forEach((p) =>{
          if(i.id === p.id){
            i.levelsValue = p.levelsValue
          }
        })
      })
      },
      newCertificate(){
      // 资质证书
      if(this.qualification){
        // this.dataForm.certificateType = 1
          this.dataForm.certificateType = 1,
          this.dataForm.name='',
          this.dataForm.code='',
          this.dataForm.qualification='',
          this.dataForm.releaseDate='',
          this.dataForm.expireDate='',
          this.dataForm.releaseOrgan='',
          this.dataForm.corporateName='',
          this.dataForm.registeredAddress='',
          this.dataForm.registeredCapital='',
          this.dataForm.remark='',
          this.dataForm.longTerm=0,
          // iso
          this.dataForm.authOrgan='',
          this.dataForm.authStandards='',
          this.dataForm.coverage='',
          // 荣誉
          this.dataForm.level=1,
          this.disabledRow  = true
      }
      if(this.dataRow && !this.qualification){
        this.dataForm.certificateType = 1
        this.disabledRow  = true
        this.dataForm = {...this.dataForm , ...this.dataRow}
        this.dataForm.releaseDate = new Date(this.dataRow.releaseDate)
        if(this.dataRow.longTerm == 1){
          this.checked = true
          this.expireDate = ''
        }
        // console.log(this.dataRow);
        if(this.dataRow){
        this.checkList = this.dataRow.confInfoList
        this.levelsIds = this.dataRow.levels
//         this.checkList.forEach(item => {
// 　　          this.$set(item,'levelsValue','')
//              })
      //   this.checkList.forEach((u,index)=>{
      //   u.levelsValue = this.levelsIds[index]
      // })
        }
        // this.dataRow.qualifications.forEach((a) =>{
        // // this.getCheck.push(a)
        // })
        }
      if(this.ISO){
          this.dataForm.certificateType = 2,
          this.dataForm.name='',
          this.dataForm.code='',
          this.dataForm.qualification='',
          this.dataForm.releaseDate='',
          this.dataForm.expireDate='',
          this.dataForm.releaseOrgan='',
          this.dataForm.corporateName='',
          this.dataForm.registeredAddress='',
          this.dataForm.registeredCapital='',
          this.dataForm.remark='',
          this.dataForm.longTerm=0,
          // iso
          this.dataForm.authOrgan='',
          this.dataForm.authStandards='',
          this.dataForm.coverage='',
          // 荣誉
          this.dataForm.level=1,
          this.disabledRow  = true
      }
      if(this.dataIsoRow && !this.ISO){
        this.dataForm.certificateType = 2,
        this.disabledRow  = true
        this.dataForm = {...this.dataForm , ...this.dataIsoRow}
        this.dataForm.releaseDate = new Date(this.dataIsoRow.releaseDate)
        if(this.dataIsoRow.longTerm == 1){
          this.checked = true
        }
        }
      if(this.honorEdit){
        this.dataForm.certificateType = 3,
          this.dataForm.name='',
          this.dataForm.code='',
          this.dataForm.qualification='',
          this.dataForm.releaseDate='',
          this.dataForm.expireDate='',
          this.dataForm.releaseOrgan='',
          this.dataForm.corporateName='',
          this.dataForm.registeredAddress='',
          this.dataForm.registeredCapital='',
          this.dataForm.remark='',
          this.dataForm.longTerm=0,
          // iso
          this.dataForm.authOrgan='',
          this.dataForm.authStandards='',
          this.dataForm.coverage='',
          // 荣誉
          this.dataForm.level=1,
          this.disabledRow  = true
      }
      if(this.dataHonorRow && !this.honorEdit){
        this.dataForm.certificateType = 3,
        this.disabledRow  = true
        this.dataForm = {...this.dataForm , ...this.dataHonorRow}
        this.dataForm.releaseDate = new Date(this.dataHonorRow.releaseDate)
        
        if(this.dataHonorRow.longTerm == 1){
          this.checked = true
        }
        }
      if(this.restEdit){
          this.dataForm.certificateType = 4,
          this.dataForm.name='',
          this.dataForm.code='',
          this.dataForm.qualification='',
          this.dataForm.releaseDate='',
          this.dataForm.expireDate='',
          this.dataForm.releaseOrgan='',
          this.dataForm.corporateName='',
          this.dataForm.registeredAddress='',
          this.dataForm.registeredCapital='',
          this.dataForm.remark='',
          this.dataForm.longTerm=0,
          // iso
          this.dataForm.authOrgan='',
          this.dataForm.authStandards='',
          this.dataForm.coverage='',
          // 荣誉
          this.dataForm.level=1,
          this.disabledRow  = true
      }
      if(this.dataRestRow && !this.restEdit){
        this.dataForm.certificateType = 4,
        this.disabledRow  = true
        this.dataForm = {...this.dataForm , ...this.dataRestRow}
        this.dataForm.releaseDate = new Date(this.dataRestRow.releaseDate)

        if(this.dataRestRow.longTerm == 1){
          this.checked = true
        }
        }
      },
      /**
   * 中国身份证详细验证
   */
  chinaIdentityValid: (rule, value, callback) => {
    if (!value) {
      return callback()
    }
    let city = {
      11: '北京',
      12: '天津',
      13: '河北',
      14: '山西',
      15: '内蒙古',
      21: '辽宁',
      22: '吉林',
      23: '黑龙江 ',
      31: '上海',
      32: '江苏',
      33: '浙江',
      34: '安徽',
      35: '福建',
      36: '江西',
      37: '山东',
      41: '河南',
      42: '湖北 ',
      43: '湖南',
      44: '广东',
      45: '广西',
      46: '海南',
      50: '重庆',
      51: '四川',
      52: '贵州',
      53: '云南',
      54: '西藏 ',
      61: '陕西',
      62: '甘肃',
      63: '青海',
      64: '宁夏',
      65: '新疆',
      71: '台湾',
      81: '香港',
      82: '澳门',
      91: '国外'
    }
    if (!value || !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(value)) {
      callback(new Error('身份证号格式错误'))
    } else if (!city[value.substr(0, 2)]) {
      callback(new Error('身份证号格式错误'))
    } else {
      // 18位身份证需要验证最后一位校验位
      if (value.length === 18) {
        const code = value.split('')
        // ∑(ai×Wi)(mod 11)
        // 加权因子
        const factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
        // 校验位
        const parity = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2]
        let sum = 0
        let ai = 0
        let wi = 0
        for (let i = 0; i < 17; i++) {
          ai = code[i]
          wi = factor[i]
          sum += ai * wi
        }
        if (parity[sum % 11].toString() !== code[17]) {
          callback(new Error('输入的身份证号有误'))
        }
      }
    }
    callback()
  },
      imgHandleRemove(file) {
        this.$refs.certiUpload.clearFiles()
        this.img.length = 0
      },
      imgHandlePictureCardPreview(file) {
        this.imgDialogImageUrl = file.url
        this.imageDialogVisible = true;
      },
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataGetFrom()
      },
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataGetFrom()
      },
      // 返回上一层
      returnBack(){
      this.$emit('routerBack')
      this.$refs.dataForm.resetFields()
      },
      clickChong(){
      this.dataGet.name = ''
      this.getDataGetFrom()
      },
      clickSou(){
      this.getDataGetFrom()
      },
      // 智能导入 同步数据
      dataKive(){
      this.dataForm = {...this.dataForm, ...this.dateFrom}
      },
      dataListForms(){
      this.dataForm = {...this.dataForm, ...this.dataListForm}
      if(this.dataListForm){
      if(this.dataListForm.certificateType == 1){
      this.readonly = true
      }
      if(this.dataListForm.certificateType ==3){
      this.readonlyEdit = true
      }
      }
      },
      handleDownload(file) {
      },
      init(tenantId){
        this.tenantId = tenantId
      },
      onRemove(file, fileList){
      },
      onCertiSuccess(response, file, fileList){
        this.imgDialogImageUrl = response.remoteUrl+response.fileName
        this.certiPicList = fileList
        console.log(this.certiPicList);
        console.log(23);
      },
      // onContractSuccess(response, file, fileList){
      //   this.payPic = fileList
      // },
      onError(err, file, fileList){
        this.$message.error("上传失败")
      },
      uploadUrl(){
        return this.$http.adornUrl(`/certificate/certificateInfo/upload`)
      },
      changeCertificateType(value){
      // console.log(value);
      // this.dataForm.name = ''
      // this.dataForm.idCard = ''
      // this.dataForm.mobile = ''
      // this.dataForm.academic = ''
      },
      gotoRouteHandle(){
      if(this.img){
        this.$parent.postImg()
      }
      if(this.qualification || this.ISO || this.honorEdit || this.restEdit){
       this.$emit('qualifications')
      //  console.log(1);
      }
     else if(this.abc){
      // this.$emit('qualifications')
      this.$parent.qualifications()
      //  console.log(2);
      //  this.$parent.qualificationddd()

      }else{
      //  console.log(3);
       this.$parent.qualificationddd()
      }
      },
      dataFormSubmit () {
      // this.onCertiSuccess()
      this.$refs.dataForm.validate(valid=>{
        let certiPic = '', constractPic = ''
        if(this.certiPicList.length > 0){
          for(let i in this.certiPicList){
            certiPic += this.certiPicList[i].response.fileName
          }
        }
        if(this.checked){
          this.dataForm.expireDate = ''
          this.dataForm.longTerm = 1
        }
        if(!this.checked){
          this.dataForm.longTerm = 0
        }
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
          if(this.dataForm.certificateType == 1 && this.qualification){
            this.$http({
              url: this.$http.adornUrl(`/cert/entQuali/save`),
              method: 'post',
              data: this.$http.adornData({
               'name':this.dataForm.name,
               'code':this.dataForm.code,
               'qualifications':this.dataForm.qualifications,
               'levels':this.levelsIds,
               'releaseDate':this.$dateFormat(this.dataForm.releaseDate),
               'expireDate':this.$dateFormat(this.dataForm.expireDate),
               'longTerm':this.dataForm.longTerm,
               'releaseOrgan':this.dataForm.releaseOrgan,
               'corporateName':this.dataForm.corporateName,
               'registeredAddress':this.dataForm.registeredAddress,
               'registeredCapital':this.dataForm.registeredCapital,
               'remark':this.dataForm.remark,
               'authOrgan':this.dataForm.authOrgan,
               'authStandards':this.dataForm.authStandards,
               'coverage':this.dataForm.coverage,
               'level':this.dataForm.level,
               'certiPic': certiPic,
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '添加成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                  // this.$refs.dataForm.resetFields()
                  // this.$emit('routerBack')
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
          if(this.dataForm.certificateType == 2 && this.ISO){
            this.$http({
              url: this.$http.adornUrl(`/cert/entIso/save`),
              method: 'post',
              data: this.$http.adornData({
               'name':this.dataForm.name,
               'code':this.dataForm.code,
               'qualifications':this.dataForm.qualifications,
               'releaseDate':this.$dateFormat(this.dataForm.releaseDate),
               'expireDate':this.$dateFormat(this.dataForm.expireDate),
               'longTerm':this.dataForm.longTerm,
               'releaseOrgan':this.dataForm.releaseOrgan,
               'corporateName':this.dataForm.corporateName,
               'registeredAddress':this.dataForm.registeredAddress,
               'registeredCapital':this.dataForm.registeredCapital,
               'remark':this.dataForm.remark,
               'authOrgan':this.dataForm.authOrgan,
               'authStandards':this.dataForm.authStandards,
               'coverage':this.dataForm.coverage,
               'level':this.dataForm.level,
               'certiPic': certiPic,
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '添加成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
          if(this.dataForm.certificateType == 3 && this.honorEdit){
            this.$http({
              url: this.$http.adornUrl(`/cert/entHonor/save`),
              method: 'post',
              data: this.$http.adornData({
               'name':this.dataForm.name,
               'code':this.dataForm.code,
               'qualification':this.dataForm.qualification,
               'releaseDate':this.$dateFormat(this.dataForm.releaseDate),
               'expireDate':this.$dateFormat(this.dataForm.expireDate),
               'longTerm':this.dataForm.longTerm,
               'releaseOrgan':this.dataForm.releaseOrgan,
               'corporateName':this.dataForm.corporateName,
               'registeredAddress':this.dataForm.registeredAddress,
               'registeredCapital':this.dataForm.registeredCapital,
               'remark':this.dataForm.remark,
               'authOrgan':this.dataForm.authOrgan,
               'authStandards':this.dataForm.authStandards,
               'coverage':this.dataForm.coverage,
               'level':this.dataForm.level,
               'certiPic': certiPic,
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '添加成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
          if(this.dataForm.certificateType == 4 && this.restEdit){
            this.$http({
              url: this.$http.adornUrl(`/cert/entOther/save`),
              method: 'post',
              data: this.$http.adornData({
               'name':this.dataForm.name,
               'code':this.dataForm.code,
               'qualification':this.dataForm.qualification,
               'releaseDate':this.$dateFormat(this.dataForm.releaseDate),
               'expireDate':this.$dateFormat(this.dataForm.expireDate),
               'longTerm':this.dataForm.longTerm,
               'releaseOrgan':this.dataForm.releaseOrgan,
               'corporateName':this.dataForm.corporateName,
               'registeredAddress':this.dataForm.registeredAddress,
               'registeredCapital':this.dataForm.registeredCapital,
               'remark':this.dataForm.remark,
               'authOrgan':this.dataForm.authOrgan,
               'authStandards':this.dataForm.authStandards,
               'coverage':this.dataForm.coverage,
               'level':this.dataForm.level,
               'certiPic': certiPic,
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '添加成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
          // 修改资质证书
          if(this.dataRow && !this.qualification){
            if(certiPic == '' && this.img.length == 0){
               certiPic = ''
            }
            if(certiPic == '' && this.img.length !== 0){
               certiPic = null
            }
          this.$http({
              url: this.$http.adornUrl(`/cert/entQuali/update`),
              method: 'post',
              data: this.$http.adornData({
               'id':this.dataRow.id,
               'name':this.dataForm.name,
               'code':this.dataForm.code,
               'qualifications':this.dataForm.qualifications,
               'levels':this.levelsIds,
               'releaseDate':this.$dateFormat(this.dataForm.releaseDate),
               'expireDate':this.$dateFormat(this.dataForm.expireDate),
               'longTerm':this.dataForm.longTerm,
               'releaseOrgan':this.dataForm.releaseOrgan,
               'corporateName':this.dataForm.corporateName,
               'registeredAddress':this.dataForm.registeredAddress,
               'registeredCapital':this.dataForm.registeredCapital,
               'remark':this.dataForm.remark,
               'authOrgan':this.dataForm.authOrgan,
               'authStandards':this.dataForm.authStandards,
               'coverage':this.dataForm.coverage,
               'level':this.dataForm.level,
               'certiPic': certiPic,
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '添加成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
          // iso
          if(this.dataIsoRow && !this.ISO){
            if(certiPic == '' && this.img.length == 0){
               certiPic = ''
            }
            if(certiPic == '' && this.img.length !== 0){
               certiPic = null
            }
          this.$http({
              url: this.$http.adornUrl(`/cert/entIso/update`),
              method: 'post',
              data: this.$http.adornData({
               'id':this.dataIsoRow.id,
               'name':this.dataForm.name,
               'code':this.dataForm.code,
               'qualification':this.dataForm.qualification,
               'releaseDate':this.$dateFormat(this.dataForm.releaseDate),
               'expireDate':this.$dateFormat(this.dataForm.expireDate),
               'longTerm':this.dataForm.longTerm,
               'releaseOrgan':this.dataForm.releaseOrgan,
               'corporateName':this.dataForm.corporateName,
               'registeredAddress':this.dataForm.registeredAddress,
               'registeredCapital':this.dataForm.registeredCapital,
               'remark':this.dataForm.remark,
               'authOrgan':this.dataForm.authOrgan,
               'authStandards':this.dataForm.authStandards,
               'coverage':this.dataForm.coverage,
               'level':this.dataForm.level,
               'certiPic': certiPic,
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '添加成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
          // 荣誉
          if(this.dataHonorRow && !this.honorEdit){
            if(certiPic == '' && this.img.length == 0){
               certiPic = ''
            }
            if(certiPic == '' && this.img.length !== 0){
               certiPic = null
            }
          this.$http({
              url: this.$http.adornUrl(`/cert/entHonor/update`),
              method: 'post',
              data: this.$http.adornData({
               'id':this.dataHonorRow.id,
               'name':this.dataForm.name,
               'code':this.dataForm.code,
               'qualification':this.dataForm.qualification,
               'releaseDate':this.$dateFormat(this.dataForm.releaseDate),
               'expireDate':this.$dateFormat(this.dataForm.expireDate),
               'longTerm':this.dataForm.longTerm,
               'releaseOrgan':this.dataForm.releaseOrgan,
               'corporateName':this.dataForm.corporateName,
               'registeredAddress':this.dataForm.registeredAddress,
               'registeredCapital':this.dataForm.registeredCapital,
               'remark':this.dataForm.remark,
               'authOrgan':this.dataForm.authOrgan,
               'authStandards':this.dataForm.authStandards,
               'coverage':this.dataForm.coverage,
               'level':this.dataForm.level,
               'certiPic': certiPic,
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '添加成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
          // 其他
          if(this.dataRestRow && !this.restEdit){
            if(certiPic == '' && this.img.length == 0){
               certiPic = ''
            }
            if(certiPic == '' && this.img.length !== 0){
               certiPic = null
            }
          this.$http({
              url: this.$http.adornUrl(`/cert/entOther/update`),
              method: 'post',
              data: this.$http.adornData({
               'id':this.dataRestRow.id,
               'name':this.dataForm.name,
               'code':this.dataForm.code,
               'qualification':this.dataForm.qualification,
               'releaseDate':this.$dateFormat(this.dataForm.releaseDate),
               'expireDate':this.$dateFormat(this.dataForm.expireDate),
               'longTerm':this.dataForm.longTerm,
               'releaseOrgan':this.dataForm.releaseOrgan,
               'corporateName':this.dataForm.corporateName,
               'registeredAddress':this.dataForm.registeredAddress,
               'registeredCapital':this.dataForm.registeredCapital,
               'remark':this.dataForm.remark,
               'authOrgan':this.dataForm.authOrgan,
               'authStandards':this.dataForm.authStandards,
               'coverage':this.dataForm.coverage,
               'level':this.dataForm.level,
               'certiPic': certiPic,
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '添加成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
          }
        })
      })
      }
    }
  }
</script>

<style lang="scss" scoped>
.cuowu{
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 18px;
  color: red;
  font-weight: 700;
}
/deep/.el-select-dropdown .el-popper .is-multiple{
  // display: none !important;
  z-index: 0 !important;
}
.sousuo{
  height: 70px;
  display: flex;
  align-items: center;
  // background-color: red;
}
.guanjianzi{
  height: 40px;
  width: 85%;
  display: flex;
  align-items: center;
  float: left;
  .ziti{
    float: left;
    margin-right: 6px;
  }
  .inputss{
    float: left;
  }
}
/deep/
.dialog-s{
.el-dialog{
  margin-top: 0vh !important;
}
}
/deep/.buttons{
  width: 15%;
  height: 40px;
  float: right;
  display: flex;
  align-items: center;
  .buttonItema{
    float: right;
    font-size: 14px;
  }
  .buttonItemb{
    float: right;
    font-size: 14px;
  }
}
.button-see{
  font-size: 14px;
}
/deep/.dialog-s{
.el-dialog__header{
  padding: 20px !important;
  font-weight: 600;
  border-bottom: 1px solid #cccccc;
}
.el-dialog__body{
  padding: 0px 15px !important;
}

}
.col-buttons{
  float: right;
}
.div-mau{
  background-color: #ffffff;
}
// .itemCheck{
//   display: flex;
//   // justify-content: center;
//   align-items: center;
// }
    .demo-drawer {
        &__content {
            display: flex;
            flex-direction: column;
            height: 100%;
            form {
                flex: 1;
            }
        }
        &__footer {
            display: flex;
            button {
                flex: 1;
            }
        }
        &__header {
            text-align:right;
            margin-bottom:20px;
            width:100%;
        }
    }
    // 返回按钮
    .center-s{
      overflow: hidden;
      height: 38px;
      line-height: 38px;
      margin-bottom: 3px;
      h3{
        margin-left:30px;
        float: left;
      }
      h5{
        float: left;
        font-weight: 400;
        margin-left: 30px;
        color: orangered;
      }
      .clickBack{
      float: right;
      margin-right: 20px;
      }
    }
    .el-drawer__body {
        padding: 20px;
    }

    .el-upload-dragger{
      width: 100%;
    }
    .el-input__inner{
      height: 36px;
    }
    .clearfix:after{/*伪元素是行内元素 正常浏览器清除浮动方法*/
        content: "";
        display: block;
        height: 0;
        clear:both;
        visibility: hidden;
    }
   .clearfix{
       *zoom: 1;/*ie6清除浮动的方式 *号只有IE6-IE7执行，其他浏览器不执行*/
   }
</style>
